package org.jeecg.modules.flow.activiti.command;

import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntityManager;

/**
 * 修改历史任务命令
 */
public class UpdateHistoricTaskCmdService implements Command<Boolean> {

    protected String taskId;
    protected String deleteReason;

    public UpdateHistoricTaskCmdService(String taskId, String deleteReason) {
        this.taskId = taskId;
        this.deleteReason = deleteReason;
    }

    @Override
    public Boolean execute(CommandContext commandContext) {
        HistoricTaskInstanceEntityManager manager = commandContext.getHistoricTaskInstanceEntityManager();
        HistoricTaskInstanceEntity entity = manager.findById(taskId);
        entity.setDeleted(true);
        entity.setDeleteReason(deleteReason);
        manager.update(entity);
        return true;

    }
}
